<?php
  require_once('includes/db.php');
  require_once('includes/header.php');
  $tableName = 'users';
  $id = isset($_GET['id'])?$_GET['id']:1;
  $user = fetchById($tableName,$id);// it contain all the coloumns of particular record(id) like name,gender,pictures etc..

  $isMale = $user['gender']=='m'?'checked':'';
  $isFemale = $user['gender']=='f'?'checked':'';
  pr($user);
?>
      <!-- Main component for a primary marketing message or call to action -->
      <div class="jumbotron" style="padding: 10px;">
        <h4>Edit User :-</h4>

      </div>
      <div style="width:380px;">
 
<!-------Register Form Starts Here ----------->
      <form id="registerId" action="edit_saveuser.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?=$user['id']?>">
<input type="hidden" name="oldAvatarName" value="<?=$user['avatar']?>">
        <div class="form-group">
          <label>Name</label>
          <input type="text" class="form-control"  placeholder="Enter Name"
          name="uname" value="<?=$user['uname']?>">
        </div>

        <div class="form-group">
          <label>Email</label>
          <input disabled  type="email" class="form-control" placeholder="Email"
          value="<?=$user['email']?>" name="email">
        </div>

        <div class="form-group">
          <label>Select Gender</label>
          <div class="radio">
            <label>
              <input type="radio" <?=$isMale?> name="gender"  value="m">
              Male
            </label>
          </div>
          <div class="radio">
            <label>
              <input type="radio" <?=$isFemale?> name="gender"  value="f">
              Female
            </label>
          </div>
          <div><label class="alert-danger" generated="true" for="gender"></label></div>
        </div><!-- end form-group gender-->

        <div class="form-group">
          <label>Date Of Birth</label>
          <input disabled type="text" class="form-control" placeholder="__-__-____"
          value="<?=$user['dob']?>" name="dob" id="dobId">

        </div>

        <div class="form-group">
          <label>Country</label>
          <select name="country_id" class="form-control">
            <option value="">-SELECT-</option>
            <?php

            $countries = getCountries();
            foreach ($countries as $code=>$cname) {
            $selected = ($code == $user['country_id'])? 'selected':'';
              echo "<option $selected value=\"$code\">$cname</option>";
            }
            ?>
          </select>
        </div>

        <div class="form-group">
          <label for="exampleInputFile">Upload Avatar</label>
          <input type="file" name="e_avatar">
          <p class="help-block">(png,jpeg,bmp)</p>
          <img src="uploads/thumbs_120_90/<?=$user['avatar']?>">
        </div>

        <button type="submit" class="btn btn-primary btn-lg">I am done !!</button>
      </form>
      </div>

<?php
 require_once('includes/footer.php');?>
